﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenComposite.Base;

namespace OpenComposite.SOBADesigner.Designers
{
	public partial class NewPasswordForm : Form
	{
		public NewPasswordForm()
		{
			InitializeComponent();
			this.DialogResult = DialogResult.Cancel;
		}

		public string Password
		{
			get { return Helper.GetHashedString(txtNewPassword.Text); }
		}

		private void tsbtnOk_Click(object sender, EventArgs e)
		{
			if ( txtNewPassword.Text == txtConfirmPassword.Text ) {
				if ( txtNewPassword.Text.Length < 5 ) {
					MessageBox.Show("Please choose a longer password!", "Password too simple",
						MessageBoxButtons.OK, MessageBoxIcon.Error);
				} else {
					this.DialogResult = DialogResult.OK;
					this.Close();
				}
			} else {
				MessageBox.Show("Passwords don't match! Please check again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				txtNewPassword.Text = "";
				txtConfirmPassword.Text = "";
				txtNewPassword.Focus();
			}
		}
	}
}
